package love.yuanmengrobot.springmvcdemo2.controller;

import love.yuanmengrobot.springmvcdemo2.pojo.Users;
import love.yuanmengrobot.springmvcdemo2.service.UserService;
import love.yuanmengrobot.springmvcdemo2.utils.DataGridView;
import love.yuanmengrobot.springmvcdemo2.utils.ResultObj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 *   @Studio:CHJY · 源梦科技
 *   @Author:CHJY创幻
 *   @Ide:IntelliJ IDEA
 *   @Creation time:2021/7/14 9:08
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;
    /**
     * 查询所有的 及模糊查询
     *
     * @param users
     * @return
     */
    @RequestMapping("/loadAllUser")
    public DataGridView loadAllUser(Users users) {
        return this.userService.queryAllUser(users);
    }

    @RequestMapping("/login")
    public ResultObj login(Users users) {
        Users user = this.userService.login(users);
        if(null!=user){
            return ResultObj.LOGIN_SUCCESS;
        }else {
            return ResultObj.LOGIN_ERROR;
        }
    }

}
